<?php
$GLOBALS['Md'] = "RHUSJW24";
$GLOBALS['Pd'] = "B";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($GLOBALS['PAD']."Modules/FJK46JDE/modconf.php"); 
MYTCONN();

		$QGroups = '';
		$QOffices = '';
		$QStatus = '';
		

		if ($_POST['SYSOffices'] != '') {
		
		$QStatus = ' AND smb_Domain = '.$_POST['SYSOffices'];
		
		}
		if ($_POST['SYSUserStatus'] != '') {
		
		$QOffices = ' AND smb_Flag = '.$_POST['SYSUserStatus'];
		
		}
		if ($_POST['SYSUserGroups'] != '') {
		
		$QGroups = ' AND usr_UserGroup = '.$_POST['SYSUserGroups'];

		}
		
		$GET = $GLOBALS['MYT']->db_array("SELECT
				smb_ID AS COLID,
				smb_Name AS COL1,
				smb_CODE AS COL2,
				smb_Flag AS COL3,
				smb_BirthDate AS COL4,
				smb_CttEmail AS COL5
				FROM systemoffice.staff_members
		WHERE smb_Flag > 0 {$QStatus} {$QOffices} {$QGroups}");
	$CARD = $GET[0];
	?>
<script charset="utf-8" type="text/javascript">

Ext.onReady(function(){

    var myData = [
	<?php   
	for ($i=1;$i<=$CARD;$i++) {
	echo "[{$i},'{$GET[$i]['COLID']}','{$GET[$i]['COL1']}','{$GET[$i]['COL2']}','{$GET[$i]['COL4']}','{$GET[$i]['COL3']}','{$GET[$i]['COL5']}']";
		if ($i<$CARD) {
			echo ',';
		}
    } ?>
    ];

    var ds = new Ext.data.Store({
        reader: new Ext.data.ArrayReader({}, [
               {name: 'id'},
			   {name: 'COLID', type: 'int'},
               {name: 'COL1', type: 'string'},
               {name: 'COL2', type: 'string'},
               {name: 'COL4', type: 'string'},
               {name: 'COL3', type: 'string'},
               {name: 'COL5', type: 'string'}
          ])
    });
    ds.loadData(myData);
    var colModel = new Ext.grid.ColumnModel([
        {header: "Numero", width: 80, sortable: true, locked:true, dataIndex: 'COLID'},
        {header: "Nome", width: 200, sortable: true, locked:true, dataIndex: 'COL1'},
        {header: "N Funcionario", width: 150, sortable: true, dataIndex: 'COL2'},
        {header: "Data de Nascimento", width: 150, sortable: true, locked:true,dataIndex: 'COL4'},
        {header: "Estado", width: 150, sortable: true, locked:true,dataIndex: 'COL3'},
        {header: "Email", width: 150, sortable: true, locked:true,dataIndex: 'COL5'}
    ]);

   var selmode = new Ext.grid.RowSelectionModel({});
   var Console = new Ext.grid.GridPanel({
	            ds: ds,
	            cm: colModel,
	            sm: selmode,
				listeners: {
	 				rowdblclick: function(ds, row) { 
					var record = ds.getStore().getAt(row);
  					var value = record.get('COLID');	
					idwindow('Dados do Funcionario','user_properties','user_form','<?php echo $MODURL;?>Lib/frm_staffmember.php?RSID='+value,650,500);
					 }
				},
	    height: 400,
        renderTo: 'UserList'
    });
		
});
</script>